/**
 * 
 */
package com.bms.web;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.bms.Logic;
import com.bms.abstracts.RESTController;
import com.bms.domain.Event;

/**
 * @author IBM
 *
 */
public class SummaryListController extends RESTController {
	
	private Logic logic;
	
	public void setLogic(Logic logic) {
		this.logic = logic;
	}
	
	/* (non-Javadoc)
	 * @see com.bms.abstracts.RESTController#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ModelAndView doGet(HttpServletRequest request,
			HttpServletResponse response) {
		
		List<Event> list = new ArrayList<Event>();
		
		String userid = request.getParameter("userid");
		String groups = request.getParameter("groups");
		
		if("".equals(userid) && !"".equals(groups)){
			list = logic.getGongZuoZongJiefromGroup(groups);
		}
		if(!"".equals(userid) && "".equals(groups)){
			list = logic.getGongZuoZongJiefromUserid(userid);
		}
		if("".equals(userid) && "".equals(groups)){
			list = logic.getGongZuoZongJieList();
		}
		return new ModelAndView("summarylist","list",list);
	}

	/* (non-Javadoc)
	 * @see com.bms.abstracts.RESTController#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	protected ModelAndView doPost(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		return null;
	}

}
